Conditional execution of script inside script

Hello,

I have two separate scripts used each independently :

  • FisrtScript.dxl
  • SecondScript.dxl

I need write a new script. In this third script execution of the SecondScript depends result of first, like this :
if FisrtScript.dxl is true then execute SecondScript.dxl.

I don't find how to do.
Is it possible ?

Thanks
Pierre
PDU - Mon Mar 15 05:38:01 EDT 2010

Re: Conditional execution of script inside script
Ben_Sharples - Mon Mar 15 07:08:24 EDT 2010

if you put the whole of your first script into a separate boolean function, which returns true if it suceeds succesfully. (I would also be tempted to save this new function in a separate include file.
 

bool firstScript {
 
firstScript.dxl
 
return true   - if criteria met for firstScript
 
}

 


do the same with the second script (save as an include file)

the third script should now look something like this:

 

 

 

<#include firstScript.inc>
<#include secondScript.inc>
 
if (firstScriptBoolFunction) {
 
        secondScriptFunction.inc>
}



hope this helps



 

 

Re: Conditional execution of script inside script
PDU - Mon Mar 15 09:49:38 EDT 2010

Ben_Sharples - Mon Mar 15 07:08:24 EDT 2010

if you put the whole of your first script into a separate boolean function, which returns true if it suceeds succesfully. (I would also be tempted to save this new function in a separate include file.
 

bool firstScript {
 
firstScript.dxl
 
return true   - if criteria met for firstScript
 
}

 


do the same with the second script (save as an include file)

the third script should now look something like this:

 

 

 

<#include firstScript.inc>
<#include secondScript.inc>
 
if (firstScriptBoolFunction) {
 
        secondScriptFunction.inc>
}



hope this helps



 

 

OK,

it works fine, for some scripts.
My first script use DBE, and DB variables (panel with fields).
==> errors, i need declare DBE variables outside firstScript function.

But my second scripts use crypted include, so i have "non local variable access" messages, and no solution.

Pierre

Re: Conditional execution of script inside script
Mathias Mamsch - Mon Mar 15 18:09:45 EDT 2010

PDU - Mon Mar 15 09:49:38 EDT 2010
OK,

it works fine, for some scripts.
My first script use DBE, and DB variables (panel with fields).
==> errors, i need declare DBE variables outside firstScript function.

But my second scripts use crypted include, so i have "non local variable access" messages, and no solution.

Pierre

There is a special pattern on how remote control (start) a gui script from another script and evaluate the results.

Usually GUI scripts have show command in them (which practically ends execution after the script). You redeclare the show function to make it a "block" statement which will return after execution.
 

// ---  firstscript.dxl ----
DB diag
DBE dbeField
 
void makeDiag(int x) {
    diag = centered "First Script"
        dbeField = field(diag, "", x "", 30, false)
}
 
makeDiag(10) 
show diag
 
// --- secondScript.dxl ---
 
ack "The user entered 10."
 
// ----------- thirdscript.dxl -----------
 
// trick: redeclare the show method to enable us 
// to continue after firstscript
void show(DB x) {
        block x
}
 
#include <firstScript.dxl>
 
// here we use the global variables of the first script!
release diag
hide diag
string val = get dbeField
 
// condition for secondscript
if (val != 10) halt
 
#include <secondScript.dxl>
 
// you could have done something like this:
// if (val == 10) { eval_ "#include <secondScript.dxl>" }

 


If firstScript and secondScript have global variables with the same name, then it gets a little ugly you would have to use the "eval_" command to separate them and pass the data from one script to the other. I am not 100% sure, but I would say that in almost all cases you should be able to get the result you want. Maybe you can tell a little more about the specific structure of the scripts, then it would be easier to help you.

Regards, Mathias

 

Re: Conditional execution of script inside script
PDU - Wed Mar 17 03:09:15 EDT 2010

Mathias Mamsch - Mon Mar 15 18:09:45 EDT 2010

There is a special pattern on how remote control (start) a gui script from another script and evaluate the results.

Usually GUI scripts have show command in them (which practically ends execution after the script). You redeclare the show function to make it a "block" statement which will return after execution.
 

// ---  firstscript.dxl ----
DB diag
DBE dbeField
 
void makeDiag(int x) {
    diag = centered "First Script"
        dbeField = field(diag, "", x "", 30, false)
}
 
makeDiag(10) 
show diag
 
// --- secondScript.dxl ---
 
ack "The user entered 10."
 
// ----------- thirdscript.dxl -----------
 
// trick: redeclare the show method to enable us 
// to continue after firstscript
void show(DB x) {
        block x
}
 
#include <firstScript.dxl>
 
// here we use the global variables of the first script!
release diag
hide diag
string val = get dbeField
 
// condition for secondscript
if (val != 10) halt
 
#include <secondScript.dxl>
 
// you could have done something like this:
// if (val == 10) { eval_ "#include <secondScript.dxl>" }

 


If firstScript and secondScript have global variables with the same name, then it gets a little ugly you would have to use the "eval_" command to separate them and pass the data from one script to the other. I am not 100% sure, but I would say that in almost all cases you should be able to get the result you want. Maybe you can tell a little more about the specific structure of the scripts, then it would be easier to help you.

Regards, Mathias

 

Thanks very much Mathias, this works fine.

For second script, i need use

eval_ "#include <secondScript.dxl>"

.
If i use

#include <secondScript.dxl>

, after execution of this script, DOORS is blocked (ALT-CTRL-DEL !).
This second script is encrypted (Twexp export), so i don't see what appends.
DXL is a very strange language, with bad documentation ....
Regards
Pierre

Re: Conditional execution of script inside script
Mathias Mamsch - Wed Mar 17 13:43:33 EDT 2010

PDU - Wed Mar 17 03:09:15 EDT 2010

Thanks very much Mathias, this works fine.

For second script, i need use

eval_ "#include <secondScript.dxl>"

.
If i use

#include <secondScript.dxl>

, after execution of this script, DOORS is blocked (ALT-CTRL-DEL !).
This second script is encrypted (Twexp export), so i don't see what appends.
DXL is a very strange language, with bad documentation ....
Regards
Pierre

There are usually three reasons why a DOORS script locks up:
1. You are caught in a very long computation
2. You forgot to put a stopProgress after a startProgress
3. You forgot to put a release after a block

If you redefine your show function to use block instead, you must always use a release command somewhere after, because if the secondScript uses show it certainly does NOT use release. My guess is, that your script locks up because you did not use release. You can try to put it like this:
 

void show(DB x) {
    block x
    // get data from the main dialog here if you need to 
    // ...
    release x
}

 


Regards, Mathias